package com.example.controller;

import com.example.pojo.Comment;
import com.example.service.ICommentService;
import com.example.util.R;
import com.example.vo.UserComment;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/comments")
@Api(tags = "评论api接口")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    @ApiOperation("查询全部")
    @GetMapping("/content/all")
    public R<List<Comment>> getAllContents() {
        return R.success("成功", commentService.getAllComments());
    }

    @ApiOperation("查询单个")
    @GetMapping("/content/{id}")
    public R<List<UserComment>> getContentById(@PathVariable("id") Long contentId) {
        return R.success("成功", commentService.getCommentsByContentId(contentId));
    }
}
